package com.yzkj.siot.context;


import com.yzkj.siot.uesr.dto.CurrentUser;

public class CurUserCtx {
    private static final ThreadLocal<CurrentUser> context = new ThreadLocal<>();

    // 构造方法私有化
    private CurUserCtx() {
    }

    /**
     * 存放用户信息
     */
    public static void set(CurrentUser currentUser) {
        context.set(currentUser);
    }

    /**
     * 获取用户信息
     */
    public static CurrentUser get() {
        return context.get();
    }

    /**
     * 清除当前线程内引用，防止内存泄漏
     */
    public static void remove() {
        context.remove();
    }
}